import request from '@/utils/service'
export default {
    login(user) {
        return request({
            method: "post",
            url: "/user/login",
            data: user
        })
    },
    register(user) {
        return request({
            method: "post",
            url: "/user/register",
            data: user
        })
    },
    getCode(username) {
        return request({
            method: "get",
            url: "/user/vc.jpg",
            params: {
                username
            }
        })
    },
    getUserInfo(id, access) {
        return request({
            method: "get",
            url: `/user/get/info/${id}`,
            headers: {
                Authorization: "token:" + access, //指定消息格式
            },
        })
    },
    tokenRefresh(refresh) {
        return request({
            method: "post",
            url: `/user/token/refresh`,
            params: {
                refresh
            }
        })
    },
    updateUserFrom(userfrom,access){
        return request({
            method: "post",
            url: `/user/update/info`,
            data: userfrom,
            headers: {
                Authorization: "token:" + access, //指定消息格式
            },
        })
    },
    getUserFrom(access){
        return request({
            method: "get",
            url: `/user/getuserfrom`,
            headers: {
                Authorization: "token:" + access, //指定消息格式
            },
        })
    },
    updateAvatarURL(avatar,access){
        return request({
            method: "put",
            url: `/user/avatar`,
            params:{
                avatar
            },
            headers: {
                Authorization: "token:" + access, //指定消息格式
            },
        })
    },
    updatePassword(PasswordDto,access){
        console.log(PasswordDto)
        return request({
            method: "put",
            url: `/user/password`,
            data: PasswordDto
             ,
            headers: {
                Authorization: "token:" + access, //指定消息格式
            },
        })
    }
}